package com.dmc.hrl.domain.entity;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * Controller层返回结果信息类
 * 
 * @author Peng
 *
 * @param <T>
 */
@ApiModel(value = "结果对象模型")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> implements Serializable {

	@JSONField(ordinal = 1)
	@ApiModelProperty(value = "成功情况",position = 1)
	private boolean success;

	@JSONField(ordinal = 2)
	@ApiModelProperty(value = "结果编码",position = 2)
	private int code;

	@JSONField(ordinal = 3)
	@ApiModelProperty(value = "结果信息",position = 3)
	private String message;
	
	@JSONField(ordinal = 4)
	@ApiModelProperty(value = "数据信息",position = 4)
	private T data;

	private static final long serialVersionUID = 1L;
	
	/**
	 * 	兼容旧版本（过时），新版本采用ResultEntity
	 * @param success
	 * @param message
	 */
	@Deprecated
	public Result(boolean success, String message) {
		super();
		this.success = success;
		this.message = message;
	}
	/**
	 * 	兼容旧版本（过时），新版本采用ResultEntity
	 * @param success
	 * @param message
	 * @param data
	 */
	@Deprecated
	public Result(boolean success, String message, T data) {
		super();
		this.success = success;
		this.message = message;
		this.data = data;
	}
}
